package ordenesBeans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.RowEditEvent;


@ManagedBean(name = "ord")
@ApplicationScoped
public class ordenes implements Serializable {
     private static final long serialVersionUID = 2L;
     private int noorden;
     private Date fech_ped;
     private String prod;
     private int cant;
     private Date fech_ent;
     private String lug_ent;
     
    
    ordenBeans ord;

    public int getNoorden() {
        return noorden;
    }

    public void setNoorden(int noorden) {
        this.noorden = noorden;
    }

    public Date getFech_ped() {
        return fech_ped;
    }

    public void setFech_ped(Date fech_ped) {
        this.fech_ped = fech_ped;
    }

    public String getProd() {
        return prod;
    }

    public void setProd(String prod) {
        this.prod = prod;
    }

    public int getCant() {
        return cant;
    }

    public void setCant(int cant) {
        this.cant = cant;
    }

    public Date getFech_ent() {
        return fech_ent;
    }

    public void setFech_ent(Date fech_ent) {
        this.fech_ent = fech_ent;
    }

    public String getLug_ent() {
        return lug_ent;
    }

    public void setLug_ent(String lug_ent) {
        this.lug_ent = lug_ent;
    }

    

    
    //-------------------------------------------------------------------
    
    public ordenBeans getOrden(){
    return ord;
    }
    public void setOrdens(ordenBeans ord){
    this.ord = ord;
    }
    
    private static final ArrayList<ordenBeans> orderList = new ArrayList<ordenBeans>();
    
    public ArrayList<ordenBeans> getOrderList(){
    return orderList;
    }
    
    public String addAction(){
    ordenBeans dataOrden = new ordenBeans (this.noorden,this.fech_ped,this.prod,this.cant,this.fech_ent,this.lug_ent);
    orderList.add(dataOrden);
    noorden=0;
    fech_ped=null;
    prod="";
    cant=0;
    fech_ent=null;
    lug_ent="";
    
    return null;
    
    }
    
    public void onEdit(RowEditEvent event) {  
        FacesMessage msg = new FacesMessage("Órden Editada",((ordenBeans) event.getObject()).getProd());  
        FacesContext.getCurrentInstance().addMessage(null, msg);  
    }  
       
    public void onCancel(RowEditEvent event) {  
        FacesMessage msg = new FacesMessage("Órden Eliminada");
        FacesContext.getCurrentInstance().addMessage(null, msg);
        orderList.remove((ordenBeans) event.getObject());
    }    
    
    
    
}
